package net.seayan.designpattern4j.builder.model;

import java.util.ArrayList;

/**
 * 建造者模式
 * 以洗衣機洗衣服為例
 * @author seasalt
 *
 */
public abstract class AbstractWashMachine {
	
	//保存一次洗衣服的順序
	private ArrayList<OptList> runSequence=new ArrayList<OptList>();
	
	//浸洗
	protected abstract void dip();
	
	//洗滌
	protected abstract void wash();
	
	//漂洗
	protected abstract void rinse();
	
	//脫水
	protected abstract void dehydration();
	
	public final void run(){
		
		for(int i=0;i<runSequence.size();i++){
			
			OptList op=runSequence.get(i);
			if(op.equals(OptList.DIP))
				this.dip();
			else if(op.equals(OptList.WASH))
				this.wash();
			else if(op.equals(OptList.RINSE))
				this.rinse();
			else if(op.equals(OptList.DEHYDRATION))
				this.dehydration();
		}
	}
	
	public final void setRunSequence(ArrayList<OptList> opt){
		this.runSequence=opt;
	}
	
}
